import axios from '@/https/index'

// 1.团购主页
export const groupAxios=(currentPage,pageSize)=>{
    return new Promise((resolve,reject)=>{
        axios({
            url:'http://172.16.101.63:8001/buy/queryAllBuy',
            method:'GET',
            params:{
                currentPage:currentPage,
                pageSize:pageSize
            }
        })
        .then((res)=>{
            resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
}

//2.团购详情
export const groupDetailsAxios=(id)=>{
    return new Promise((resolve,reject)=>{
        axios({
            url:'http://172.16.101.63:8001/buy/queryByNameCh',
            method:'GET',
            params:{
               id:id
            }
        })
        .then((res)=>{
            resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
}

//3.新增团购活动
export const addGroupAxios=(obj)=>{
    return new Promise((resolve,reject)=>{
        axios({
            url:'http://172.16.101.47:8111/groupBuyManagement/addGroupBuy',
            method:'POST',
            data:{
               obj
            }
        })
        .then((res)=>{
            resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
}

//4.编辑团购活动
export const editGroupAxios=(obj)=>{
    return new Promise((resolve,reject)=>{
        axios({
            url:'http://172.16.101.47:8111/groupBuyManagement/updateGroupBuy',
            method:'POST',
            data:{
               obj
            }
        })
        .then((res)=>{
            resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
}

//5.访问订单
export const orderAxios=(shopChineseName,currentPage,pageSize)=>{
    return new Promise((resolve,reject)=>{
        axios({
            url:'http://172.16.101.47:8111/groupBuyManagement/findOrder',
            method:'GET',
            params:{
                shopChineseName:shopChineseName,
                currentPage:currentPage,
                pageSize:pageSize
            }
        })
        .then((res)=>{
            resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
}

